// LoginResult.java
package com.ruoyi.nongjt.domain;

import com.ruoyi.nongjt.domain.NjtUserRegister;
import lombok.Data;

/**
 * 登录结果
 * @author zhouyihao
 */
@Data
public class LoginResult {

    /** 登录是否成功 */
    private Boolean success;

    /** 消息 */
    private String message;

    /** 令牌 */
    private String token;

    /** 用户信息 */
    private UserInfo userInfo;
    
    /** 资料完善状态 0:未完善 1:审核中 2:审核通过 3:审核拒绝 */
    private String perfectStatus;
    
    /** 审核意见 */
    private String auditRemark;

    public static LoginResult success(String token, NjtUserRegister user) {
        LoginResult result = new LoginResult();
        result.setSuccess(true);
        result.setMessage("登录成功");
        result.setToken(token);

        UserInfo userInfo = new UserInfo();
        userInfo.setId(user.getId());
        userInfo.setUsername(user.getMobilePhone()); // 使用手机号作为用户名
        userInfo.setNickname(user.getCompanyName());
        userInfo.setAvatar("/static/avatar.png");
        userInfo.setRole("user");

        result.setUserInfo(userInfo);
        return result;
    }

    public static LoginResult error(String message) {
        LoginResult result = new LoginResult();
        result.setSuccess(false);
        result.setMessage(message);
        return result;
    }

    // getter和setter
    public Boolean getSuccess() { return success; }
    public void setSuccess(Boolean success) { this.success = success; }
    public String getMessage() { return message; }
    public void setMessage(String message) { this.message = message; }
    public String getToken() { return token; }
    public void setToken(String token) { this.token = token; }
    public UserInfo getUserInfo() { return userInfo; }
    public void setUserInfo(UserInfo userInfo) { this.userInfo = userInfo; }

    public static class UserInfo {
        private Long id;
        private String username;
        private String nickname;
        private String avatar;
        private String role;

        // getter和setter
        public Long getId() { return id; }
        public void setId(Long id) { this.id = id; }
        public String getUsername() { return username; }
        public void setUsername(String username) { this.username = username; }
        public String getNickname() { return nickname; }
        public void setNickname(String nickname) { this.nickname = nickname; }
        public String getAvatar() { return avatar; }
        public void setAvatar(String avatar) { this.avatar = avatar; }
        public String getRole() { return role; }
        public void setRole(String role) { this.role = role; }
    }
}